package com.iot.hmi;

import com.iot.hmi.controller.SiemensWindowsController;
import javafx.application.Application;
import javafx.application.Platform;
import javafx.fxml.FXMLLoader;
import javafx.geometry.Rectangle2D;
import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.stage.Screen;
import javafx.stage.Stage;
import javafx.stage.WindowEvent;

public class StartApplication extends Application {

    public static void main(String[] args) {
        launch(args);
    }

    @Override
    public void start(Stage primaryStage) throws Exception {
        try {
            FXMLLoader fxmlLoader = SiemensWindowsController.getFxmlLoader();
            Parent root = fxmlLoader.load();
            primaryStage.setTitle("中车四方股份数据采集终端 V1.0");
            Scene scene = new Scene(root);
            primaryStage.setScene(scene);

            // 设置舞台初始尺寸为屏幕尺寸
            Screen primaryScreen = Screen.getPrimary();
            Rectangle2D bounds = primaryScreen.getBounds();
            primaryStage.setWidth(bounds.getWidth());
            primaryStage.setHeight(bounds.getHeight());

            primaryStage.show();
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    private void exit(WindowEvent windowEvent) {
        Platform.exit();
    }
}
